/*
 * @Author: your name
 * @Date: 2022-01-01 22:02:58
 * @LastEditTime: 2022-01-02 22:52:29
 * @Description:
 */
import { InjectionKey } from 'vue'
import { createStore, Store, useStore as baseUseStore } from 'vuex'
import { State } from './type'

// 定义 injection key
export const key: InjectionKey<Store<State>> = Symbol('store')

// 创建一个新的 store 实例
export const store = createStore<State>({
  state () {},
  mutations: {}
})

// 简化 useStore 用法
// 定义自己的 `useStore` 组合式函数
export function useStore () {
  return baseUseStore(key)
}
